<!-- Copyright (c) 2019-2020 十三 all rights reserved. -->
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="mall/header::head-fragment('NewBee商城-秒杀商品列表','seckill-list')">
</head>
<body>
<header th:replace="mall/header::header-fragment"></header>
<!-- nav -->
<nav th:replace="mall/header::nav-fragment"></nav>

<div class="seckill-title">
    <img class="seckill-img" src="https://newbee-mall.oss-cn-beijing.aliyuncs.com/miaosha-bg.png">
</div>

<div class="goods_item center">
    <div class="main center" id="seckill-list">

    </div>
    <div class="pages">
        <div class="page_wrap">
        </div>
    </div>
</div>

<div th:replace="mall/footer::footer-fragment"></div>
<!-- jQuery -->
<script th:src="@{/admin/plugins/jquery/jquery.min.js}"></script>
<script th:src="@{/mall/js/search.js}" type="text/javascript"></script>
<script th:inline="javascript"> var _ctx = [[@{/}]]; </script>
<script>
    $(function () {
        $.ajax({
            url: _ctx + 'seckill/list',
            datatype: 'json',
            success: function (res) {
                if (res.resultCode != 200) {
                    wal(result.message, {
                        icon: "error",
                    });
                    return;
                }
                $('#seckill-list').html('');
                var seckillList = res.data;
                var seckillContent = '';
                for (var i = 0; i < seckillList.length; i++) {
                    var seckill = seckillList[i];
                    seckillContent += '<div class="item_card_frame" onclick="gotoSeckillDetail(' + seckill.seckillId + ')">\n' +
                        '                    <div class="item_card">\n' +
                        '                        <img src="' + seckill.goodsCoverImg + '" alt="' + seckill.goodsName + '">\n' +
                        '                    </div>\n' +
                        '                    <div class="item_brand">' + seckill.goodsName + '</div>\n' +
                        '                    <div class="item_sub_intro">秒杀时段：' + seckill.seckillBeginTime + ' → ' + seckill.seckillEndTime + '</div>\n' +
                        '                    <div class="seckill_price">\n' +
                        '                        ' + seckill.seckillPrice +
                        '                        <del>' + seckill.sellingPrice + '</del>\n' +
                        '                        <button class="btn-danger">立即抢购</button>\n' +
                        '                    </div>\n' +
                        '                </div>';
                }
                seckillContent +='<div class="clear"></div>';
                if (seckillContent) {
                    $('#seckill-list').html(seckillContent);
                } else {
                    $('#seckill-list').html('<img style="margin-top: 16px;padding: 16px 20px;" src="' + _ctx + 'mall/image/null-content.png">');
                }
            }
        })
    })

    function gotoSeckillDetail(seckillId) {
        window.location.href = _ctx + 'seckill/info/' + seckillId;
    }
</script>
</body>
</html>
